<%--
  Created by IntelliJ IDEA.
  User: Ice Bear
  Date: 2022/11/21
  Time: 21:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Login</title>
    <script src="/library/layui-v2.7.6/layui/layui.js"></script>
    <link type="text/css" rel="stylesheet" href="/library/layui-v2.7.6/layui/css/layui.css"/>
    <link type="text/css" rel="stylesheet" href="/library/view/css/all.css">
    <link type="text/css" rel="stylesheet" href="/library/view/css/login.css">
</head>
<body class="body">


<div class=" login-card">
    <div>
        <h2 class="lib-title">欢 迎 登 录</h2>
    </div>
    <div class="layui-elem-field layui-field-title ">
        <form class="layui-form" action="/library/login" method="post">
            <div class="layui-form-item input">
                <label class="layui-form-label">账户:</label>
                <div class="layui-input-block ">
                    <input type="text" name="account" value="" lay-verify="title" id="account" autocomplete="off" placeholder="账户"
                           class="layui-input" onblur="checkAccount()">
                </div>
                <label class="layui-form-label " id="accountSpan"></label>
            </div>
            <div class="layui-form-item input">
                <label class="layui-form-label ">密码:</label>
                <div class="layui-input-block">
                    <input type="password" name="password" value=""  id="password" lay-verify="required"
                           placeholder="请输入密码" autocomplete="off" class="layui-input" onblur="checkPwd();checkAll()">
                </div>
                <label class="layui-form-label " id="pwdSpan"></label>
            </div>
            <div class="card">
                <button type="submit"  id="submit" class="lib-login-but layui-btn-lg" disabled="disabled" onblur="checkAll()">登录</button>
            </div>
            <div class="card">
                <button type="button" onclick="window.location.href='/library/view/jsp/register.jsp'"  class=" lib-login-but layui-btn-lg" >注册</button>
            </div>
        </form>
    </div>
</div>


</body>
<script type="text/javascript">
    function checkPwd() {
        var pwd = document.getElementById("password").value;
        var pwdspan = document.getElementById("pwdSpan");

        if (pwd == "" || pwd == null) {
            pwdspan.innerHTML = "密码不能为空";
            pwdspan.style.color = "red";
            return false;
        }
        pwdspan.innerHTML = "";
        return true;
    }
    function checkAccount() {
        var account = document.getElementById("account").value;
        var accountspan = document.getElementById("accountSpan");
        if (account == "" || account == null) {
            accountspan.innerHTML = "账户不能为空";
            accountspan.style.color = "red";
            accountspan.innerHTML = "";
            return false;
        }
        return true;
    }
    function checkAll() {
        if (checkAccount() && checkPwd()) {
            document.getElementById("submit").disabled = false;
        }else {
            document.getElementById("submit").disabled = true;
        }
    }
</script>
</html>
